<!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by 543254352462256256524765476 (543679087098579087905709847) -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p0" exclude-result-prefixes="qti">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>


	<xsl:template match="text()"/>

	<xsl:template match="/">
		<html>
			<xsl:apply-templates/>
		</html>
	</xsl:template>

	<xsl:template match="/qti:assessmentItem/qti:itemBody">
		
		<xsl:element name="div">
			<xsl:attribute name="qticname">itemBody</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<form method="GET">
				<input type="hidden" class="qticHiddenInput" name="qid" value="qtimPlayerQuestionID"/>
				<xsl:apply-templates/>
				<br/>
				<input type="submit"></input>    <input type="reset" title="Clear"></input>
			</form>
		</xsl:element>
	</xsl:template>			
			

	<!--  Recreate all other elements without the xsl:copy  
		that seems to copy namespaces as well	 -->
	<xsl:template  match="/qti:assessmentItem/qti:itemBody//*">
		<xsl:element name="{name()}">
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
	</xsl:template>

	
	
	<!--  Recreate all other nodes (usually text nodes) -->
	<xsl:template  match="/qti:assessmentItem/qti:itemBody//node()">
		<xsl:copy>
				<xsl:for-each select="@*">
					<xsl:if test="name()=local-name()">
						<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
					</xsl:if>
				</xsl:for-each>

				<xsl:apply-templates select="node()"/>
		</xsl:copy>	
	</xsl:template>
	
	
	
	<!--  Recreate all other attributes without the xsl:copy  
		that seems to copy namespaces as well -->
	<xsl:template match="@*">
		<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
	</xsl:template>
	
	<!--  Recreate all other qualified elements without the xsl:copy  
		that seems to copy namespaces as well -->
	<xsl:template priority="0.1" match="/qti:assessmentItem/qti:itemBody//*[namespace-uri()]">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
	</xsl:template>
	
	
	
	<!--  Recreate all other qualified attributes without the xsl:copy  
		that seems to copy namespaces as well -->
	<xsl:template match="@*[namespace-uri()]">
		<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
	</xsl:template>
	
	
  
	<!--	Break workaround, so MSXML doesn't produce <br></br> -->
		
	<xsl:template match="//qti:br">
		<br/>
	</xsl:template>	
	
	
	<!--	blockQuote -->
	
	<xsl:template match="//qti:blockquote">
		<xsl:element name="span">
			<xsl:attribute name="qticname">blockquote</xsl:attribute>
			<xsl:attribute name="class">qticBlockquote</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
	</xsl:template>		
		
	
	<!--	textEntryInteraction -->
	
	<xsl:template match="//qti:textEntryInteraction">
		<xsl:element name="span">
			<xsl:attribute name="qticname">textEntryInteraction</xsl:attribute>
			<xsl:attribute name="class">qticTextEntryInteraction</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
				
			<xsl:element name="input">
				<xsl:attribute name="class">qticTextEntryInteraction</xsl:attribute>		
				<xsl:attribute name="value"><xsl:value-of select="@placeholderText"/></xsl:attribute>
				<xsl:attribute name="size">
					<xsl:value-of select="@expectedLength"/>
				</xsl:attribute>
				<xsl:attribute name="name">
					<xsl:value-of select="@responseIdentifier"/>
				</xsl:attribute>
				
				<xsl:choose>
					<xsl:when test="@patternMask">
						<xsl:attribute name="type">password</xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="type">text</xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>							
			</xsl:element>
		</xsl:element>
	</xsl:template>		
	
	
	
	<!--	extendedTextInteraction -->
	
	<xsl:template match="//qti:extendedTextInteraction">
		<xsl:element name="div">
			<xsl:attribute name="qticname">extendedTextInteraction</xsl:attribute>
			<xsl:attribute name="class">qticExtendedTextInteraction</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>

			<xsl:element name="textarea">
				<xsl:attribute name="class">qticExtendedTextInteraction</xsl:attribute>
				<xsl:attribute name="name">
					<xsl:value-of select="@responseIdentifier"/>
				</xsl:attribute>				
				<xsl:attribute name="cols">
					<xsl:value-of select="25"/> <!-- @expectedLength ?? -->
				</xsl:attribute>
				<xsl:attribute name="rows">
				
					<xsl:choose>
						<xsl:when test="@expectedLines">
							<!--<xsl:value-of select="@expectedLines"/>-->
							5
						</xsl:when>
						<xsl:otherwise>
						<!--	<xsl:value-of select="(@expectedLength div 25) + 1"/>  -->
						5
						</xsl:otherwise>
					</xsl:choose>					
				
					
				</xsl:attribute>
				<xsl:value-of select="@placeholderText"/>														
			</xsl:element>
			
		</xsl:element>
	</xsl:template>		
		
	
	<!--	extendedTextInteraction- Prompt -->
	<xsl:template match="//qti:extendedTextInteraction/qti:prompt">
		<xsl:element name="div">
			<xsl:attribute name="qticname">prompt</xsl:attribute>	
			<xsl:attribute name="class">qticExtendedTextInteractionPrompt</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
	</xsl:template>
	
	
	
		
		<!--	rubricBlock -->
	
	<xsl:template match="//qti:rubricBlock">
		<xsl:element name="div">
			<xsl:attribute name="qticname">rubricBlock</xsl:attribute>
			<xsl:attribute name="class">qticRubricBlock</xsl:attribute>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
	</xsl:template>	
	
	<!--	Choice Interaction -->
	<!--	Choice Interaction - Main Body  	 -->
	
	<!-- likert first row 		
	<xsl:template match="//qti:choiceInteraction[(/qti:assessmentItem/qti:itemBody/@class='likert')][not (preceding-sibling::*[name() = 'choiceInteraction'])]">
		<xsl:element name="table">
			<tr class="qticChoiceInteraction">
				<xsl:attribute name="qticname">choiceInteraction</xsl:attribute>
				<xsl:attribute name="class">qticChoiceInteractionBody</xsl:attribute>
				<xsl:apply-templates select="@*"/>
				<td class="qticChoiceInteractionPrompt">
					<xsl:apply-templates select="qti:prompt" mode="doPrompt"/>
				</td>
				<xsl:apply-templates select="qti:simpleChoice" mode="doSimpleChoice"/>						
			</tr>
			<xsl:apply-templates select="//qti:choiceInteraction[(/qti:assessmentItem/qti:itemBody/@class='likert') and preceding-sibling::*[name() = 'choiceInteraction']]" mode="doSubsequentRows"/>		
		</xsl:element>		
	</xsl:template>
	
	-->	
			
	<!-- likert subsequent rows
	<xsl:template match="//qti:choiceInteraction[(/qti:assessmentItem/qti:itemBody/@class='likert') and (preceding-sibling::*[name() = 'choiceInteraction'])]" mode="doSubsequentRows">
		<tr class="qticChoiceInteraction">
						<xsl:attribute name="qticname">choiceInteraction</xsl:attribute>
						<xsl:attribute name="class">qticChoiceInteractionBody</xsl:attribute>
						<xsl:apply-templates select="@*"/>
						<td class="qticChoiceInteractionPrompt">
							<xsl:apply-templates select="qti:prompt" mode="doPrompt"/>
						</td> 
						<xsl:apply-templates select="qti:simpleChoice" mode="doSimpleChoice"/>					
		</tr>	
	</xsl:template>
	-->
	
	<xsl:template match="//qti:choiceInteraction[(/qti:assessmentItem/qti:itemBody/@class='likert')]">
		<xsl:element name="table">
			<tr class="qticChoiceInteraction">
						<xsl:attribute name="qticname">choiceInteraction</xsl:attribute>
						<xsl:attribute name="class">qticChoiceInteractionBody</xsl:attribute>
						<xsl:apply-templates select="@*"/>
						<td class="qticChoiceInteractionPrompt">
							<xsl:apply-templates select="qti:prompt" mode="doPrompt"/>
						</td> 
						<xsl:apply-templates select="qti:simpleChoice" mode="doSimpleChoice"/>					
			</tr>	
		</xsl:element>
	</xsl:template>
	
	
	

	<!-- Catch (and destroy) subsequent rows already dealt with above with call from first row
	<xsl:template match="//qti:choiceInteraction[(/qti:assessmentItem/qti:itemBody/@class='likert') and (preceding-sibling::*[name() = 'choiceInteraction'])]"/>
	-->
	<!-- Do non-likert choiceInteraction	-->			
	<xsl:template match="//qti:choiceInteraction[/qti:assessmentItem/qti:itemBody/@class!='likert' or not(/qti:assessmentItem/qti:itemBody/@class) ]  ">	
					
				<xsl:element name="div">
					<xsl:attribute name="qticname">choiceInteraction</xsl:attribute>
					<xsl:attribute name="class">qticChoiceInteractionBody</xsl:attribute>
					<xsl:apply-templates select="@*"/>
					<xsl:apply-templates select="qti:prompt" mode="doPrompt"/>
					<xsl:element name="div">
						<xsl:attribute name="class">qticChoiceInteractionSimpleChoiceWrap</xsl:attribute>
						<xsl:attribute name="qticname">qticChoiceInteractionSimpleChoiceWrap</xsl:attribute>						
						<xsl:apply-templates select="qti:simpleChoice" mode="doSimpleChoice"/>
					</xsl:element>	
				</xsl:element>							
	</xsl:template>
		
	
	<!--	Choice Interaction - Prompt -->
	<xsl:template match="//qti:choiceInteraction/qti:prompt" mode="doPrompt">		
			<xsl:apply-templates select="@*"/>
			<xsl:value-of select="."></xsl:value-of>
	</xsl:template>
	
		
	<!--	Choice Interaction - Choice   --> 
	<xsl:template match="//qti:choiceInteraction/qti:simpleChoice" mode="doSimpleChoice">
		<xsl:choose>
			
			<xsl:when test="/qti:assessmentItem/qti:itemBody/@class='likert'">
		
				<xsl:element name="td">
					<xsl:apply-templates select="@*"/>
					<xsl:attribute name="qticname">simpleChoice</xsl:attribute>
					<xsl:attribute name="valign">top</xsl:attribute>			
					<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
					<xsl:apply-templates select="node()"/>
					<div class="">
						<xsl:choose>
							<xsl:when test="../@maxChoices='1'">
								<xsl:element name="input">
									<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
									<xsl:attribute name="type">radio</xsl:attribute>
									<xsl:attribute name="name"><xsl:value-of select="../@responseIdentifier"/></xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select="@identifier"/></xsl:attribute>
								</xsl:element>
							</xsl:when>
							<xsl:otherwise>
								<xsl:element name="input">
									<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
									<xsl:attribute name="type">checkbox</xsl:attribute>
									<xsl:attribute name="name"><xsl:value-of select="../@responseIdentifier"/></xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select="@identifier"/></xsl:attribute>
								</xsl:element>								
							</xsl:otherwise>
						</xsl:choose>
					</div>
				</xsl:element>
			</xsl:when>
			
			
			<xsl:otherwise>
				<xsl:element name="div">
					<xsl:attribute name="class">qticChoiceInteractionSimpleChoiceBehind</xsl:attribute>
					<xsl:attribute name="qticname">qticChoiceInteractionSimpleChoiceBehind</xsl:attribute>	
		
					<xsl:element name="div">
						<xsl:apply-templates select="@*"/>
						<xsl:attribute name="qticname">simpleChoice</xsl:attribute>			
						<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
						<span>
						<xsl:choose>
							<xsl:when test="../@maxChoices='1'">
								<xsl:element name="input">
									<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
									<xsl:attribute name="type">radio</xsl:attribute>
									<xsl:attribute name="name"><xsl:value-of select="../@responseIdentifier"/></xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select="@identifier"/></xsl:attribute>
								</xsl:element>
							</xsl:when>
							<xsl:otherwise>
								<xsl:element name="input">
									<xsl:attribute name="class">qticChoiceInteractionSimpleChoice</xsl:attribute>
									<xsl:attribute name="type">checkbox</xsl:attribute>
									<xsl:attribute name="name"><xsl:value-of select="../@responseIdentifier"/></xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select="@identifier"/></xsl:attribute>
									
								</xsl:element>								
							</xsl:otherwise>
						</xsl:choose>
						</span>
						<xsl:apply-templates select="node()"/>
					</xsl:element>
				</xsl:element>			
			
			</xsl:otherwise>	
		</xsl:choose>
	</xsl:template>
 
	<!--	Unsupported  interactions -->
	<xsl:template match="//qti:hotspotInteraction | //qti:object | //qti:associateInteraction | //qti:matchInteraction | //qti:gapMatchInteraction | //qti:inlineChoiceInteraction | //qti:hottextInteraction | //qti:hotspotInteraction | //qti:selectPointInteraction | //qti:qraphicOrderInteraction | //qti:graphicAssociateInteraction | //qti:graphicGapMatchInteraction	| //qti:positionObjectInteraction | //qti:sliderInteraction | //drawingInteraction | //qti:uploadInteraction | //qti:customInteraction">
			<xsl:element name="div">	
				<xsl:attribute name="class">qticUnsupported</xsl:attribute><xsl:value-of select="name()"></xsl:value-of> is not supported in this release, please check for an updated version at http://www.qtiva.com
				<xsl:element name="div">
					<xsl:attribute name="qticname"><xsl:value-of select="name()"></xsl:value-of></xsl:attribute>		
				</xsl:element>	
			</xsl:element>					
	</xsl:template>	
	
  
</xsl:stylesheet>